package top.huhuiyu.teachproject.controller.test;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.huhuiyu.teachproject.anno.BucketLimit;
import top.huhuiyu.teachproject.anno.Limit;
import top.huhuiyu.teachproject.base.BaseResult;

@RestController
@RequestMapping("/test/limit")
public class LimitTestController {

  @Limit(key = "/test/limit/one", timeout = 30)
  @GetMapping("/one")
  public BaseResult one() {
    return BaseResult.ok("限流通过1");
  }

  @Limit(key = "/test/limit/two", message = "自定义限流提示信息")
  @GetMapping("/two")
  public BaseResult two() {
    return BaseResult.ok("限流通过2");
  }

  @GetMapping("/nolimit")
  public BaseResult nolimit() {
    return BaseResult.ok("不限流");
  }

  @BucketLimit(key = "/test/limit/three", limit = 10, timeout = 5 * 60)
  @GetMapping("/three")
  public BaseResult three() {
    return BaseResult.ok("限流通过3");
  }

  @BucketLimit(key = "/test/limit/four", limit = 10, timeout = 5 * 60)
  @Limit(key = "/test/limit/four")
  @GetMapping("/four")
  public BaseResult four() {
    return BaseResult.ok("限流通过4");
  }

}
